<?php
namespace app\run\model;

use think\Model;
use think\Db;
class Photo extends Model{
    //详情图入库
    public static function image_insert($data){
        $res =  Db::name('image')->insertGetId($data);
        return $res;
        
    }
    //详情编辑，先查询是否有数据
    public static function product_images_sel($product_id){
         
        $res =  Db::name('product_image')->alias('a')
                ->join('image b','a.img_id=b.id')
                ->where('a.product_id',$product_id)
                ->field('b.url,b.id,a.product_id')
                ->find();
        return $res;
        
    }
    //详情默认值处理
    public static function image_value($pid){
        return Db::name('image')->where('id',$pid)->field('url')->find();
        
    }
    //编辑
    public static function image_mofify_insert($pid,$data){
        return Db::name('image')->where('id',$pid)->update($data);
        
    }
}